package visao.veiculo;


import visao.usuario.InterfaceLogin;
import visao.tipoVeiculo.InterfaceListagemTipoVeiculo;
import java.awt.*;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.accessibility.AccessibleContext;
import javax.swing.*;
import modelo.dominio.TipoVeiculo;
import modelo.dominio.Veiculo;
import modelo.persistencia.ControleAcesso;
import modelo.persistencia.PersistenciaVeiculo;

/*
 * Essa Clase monta a Interface para alteração de um Veículo
 * 
 */
public class InterfaceAlterarVeiculo extends javax.swing.JFrame{

	private final PersistenciaVeiculo persistenciaVeiculo = new PersistenciaVeiculo();
	
	/*
	 * Construtor da clase Interface Alterar Veículo
	 */
	public InterfaceAlterarVeiculo(){
		initComponents();
		
		this.setTitle("Alterações em Veículo");
		
		jButton1.setVisible(true);
		jButton2.setVisible(true);
		jButton3.setVisible(false);
		jButton4.setVisible(false);
		jButton5.setVisible(true);
		jButton6.setVisible(false);
		jCheckBox1.setVisible(false);
		jCheckBox2.setVisible(false);
		jCheckBox3.setVisible(false);
		jCheckBox4.setVisible(false);
		jCheckBox5.setVisible(false);
		jCheckBox6.setVisible(false);
		jCheckBox7.setVisible(false);
		jCheckBox8.setVisible(false);
		jCheckBox9.setVisible(false);
		jCheckBox10.setVisible(false);
		jLabel1.setVisible(true);
		jLabel2.setVisible(false);
		jLabel3.setVisible(false);
		jLabel4.setVisible(false);
		jLabel5.setVisible(false);
		jLabel6.setVisible(false);
		jLabel7.setVisible(false);
		jPanel1.setVisible(true);
		jScrollPane1.setVisible(false);
		jTextArea1.setVisible(false);
		jTextField1.setEditable(true);
		jTextField1.setText("");
		jTextField1.setVisible(true);
		jTextField2.setVisible(false);
		jTextField3.setVisible(false);
		jTextField4.setVisible(false);
		jTextField5.setVisible(false);
	}
	// fim do construtor
	
   // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jTextField2 = new javax.swing.JTextField();
        jTextField3 = new javax.swing.JTextField();
        jButton5 = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jTextField4 = new javax.swing.JTextField();
        jTextField5 = new javax.swing.JTextField();
        jCheckBox1 = new javax.swing.JCheckBox();
        jCheckBox2 = new javax.swing.JCheckBox();
        jCheckBox3 = new javax.swing.JCheckBox();
        jCheckBox4 = new javax.swing.JCheckBox();
        jCheckBox5 = new javax.swing.JCheckBox();
        jCheckBox6 = new javax.swing.JCheckBox();
        jCheckBox7 = new javax.swing.JCheckBox();
        jCheckBox8 = new javax.swing.JCheckBox();
        jCheckBox9 = new javax.swing.JCheckBox();
        jCheckBox10 = new javax.swing.JCheckBox();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jButton6 = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setResizable(false);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Alterando Dados", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Ubuntu Light", 0, 18), new java.awt.Color(76, 76, 76))); // NOI18N

        jButton3.setText("Confirmar");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
				try {
					jButtonConfirmaActionPerformed(evt);
				} catch (IOException ex) {
					Logger.getLogger(InterfaceAlterarVeiculo.class.getName()).log(Level.SEVERE, null, ex);
				}
            }
        });

        jButton4.setText("Cancelar");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCancelarActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Ubuntu Light", 0, 18)); // NOI18N
        jLabel1.setText("Placa : ");

        jLabel2.setFont(new java.awt.Font("Ubuntu Light", 0, 18)); // NOI18N
        jLabel2.setText("Modelo : ");

        jLabel3.setFont(new java.awt.Font("Ubuntu Light", 0, 18)); // NOI18N
        jLabel3.setText("Cor : ");

        jButton5.setText("Ok");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
				try {
					jButtonOkActionPerformed(evt);
				} catch (IOException ex) {
					Logger.getLogger(InterfaceAlterarVeiculo.class.getName()).log(Level.SEVERE, null, ex);
				}
            }
        });

        jLabel4.setFont(new java.awt.Font("Ubuntu Light", 0, 18)); // NOI18N
        jLabel4.setText("Marca : ");

        jLabel5.setFont(new java.awt.Font("Ubuntu Light", 0, 18)); // NOI18N
        jLabel5.setText("ID Tipo Veículo :");

        jCheckBox1.setText("Direção");

        jCheckBox2.setText("Ar Condicionado");

        jCheckBox3.setText("Air Bag");

        jCheckBox4.setText("Freios ABS");

        jCheckBox5.setText("CD MP3");

        jCheckBox6.setText("Câmera de Ré");

        jCheckBox7.setText("Alarme");

        jCheckBox8.setText("Bancos de Couro");

        jCheckBox9.setText("Roda Liga Leve");

        jCheckBox10.setText("Teto Solar");

        jLabel6.setFont(new java.awt.Font("Ubuntu Light", 0, 18)); // NOI18N
        jLabel6.setText("Opcionais :");

        jLabel7.setFont(new java.awt.Font("Ubuntu Light", 0, 18)); // NOI18N
        jLabel7.setText("Observações :");

        jTextArea1.setColumns(20);
        jTextArea1.setRows(5);
        jScrollPane1.setViewportView(jTextArea1);

        jButton6.setText("Listar Tipos Veículos");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
				try {
					jButtonListarTipoVeiculoActionPerformed(evt);
				} catch (IOException ex) {
					Logger.getLogger(InterfaceAlterarVeiculo.class.getName()).log(Level.SEVERE, null, ex);
				}
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel2)
                                    .addComponent(jLabel3)
                                    .addComponent(jLabel4))
                                .addGap(35, 35, 35))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel5)
                                    .addComponent(jLabel6)
                                    .addComponent(jLabel7))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 311, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(26, 26, 26)
                                .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(6, 6, 6)
                                .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(jTextField4, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jTextField3, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jTextField2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 219, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jCheckBox2)
                                .addGap(18, 18, 18)
                                .addComponent(jCheckBox4)
                                .addGap(18, 18, 18)
                                .addComponent(jCheckBox6)
                                .addGap(18, 18, 18)
                                .addComponent(jCheckBox8))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jCheckBox1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jCheckBox3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jCheckBox5)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jCheckBox7)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jCheckBox9)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jCheckBox10)))))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGap(32, 32, 32)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton5))
                .addGap(26, 26, 26)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(21, 21, 21)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(46, 46, 46)
                        .addComponent(jLabel3))
                    .addComponent(jLabel2))
                .addGap(31, 31, 31)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButton6))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jCheckBox1)
                            .addComponent(jCheckBox3)
                            .addComponent(jCheckBox5)
                            .addComponent(jCheckBox7)
                            .addComponent(jCheckBox9)
                            .addComponent(jCheckBox10)
                            .addComponent(jLabel6))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jCheckBox2)
                            .addComponent(jCheckBox4)
                            .addComponent(jCheckBox6)
                            .addComponent(jCheckBox8))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel7)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jButton3)
                                    .addComponent(jButton4))
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addComponent(jLabel5))
                .addContainerGap())
        );

        jButton1.setText("Logoff");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonLogoffActionPerformed(evt);
            }
        });

        jButton2.setText("Voltar");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonVoltarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 538, Short.MAX_VALUE)
                        .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jButton2))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>                        

    /*
	*Método do Botão Log Off que retorna para a janela de Controle de Acesso 
	* @param evt
	*/
	private void jButtonLogoffActionPerformed(java.awt.event.ActionEvent evt) {                                        
		dispose();
		ControleAcesso.logoff();
	}                                        
	// fim método
	
	/*
	 * Método do Botão Voltar que retorna para a janela de Menu principal
	 * @param evt
	 */
	private void jButtonVoltarActionPerformed(java.awt.event.ActionEvent evt) {                                         
		dispose();
		ControleAcesso.voltarMenuPrincipal();
	}                                                                    
	// fim método

	/*
	 * Butão que chama a interface de listagem dos tipos de veículos
	 * @param evt
	 * @throws IOException
	 */
	private void jButtonListarTipoVeiculoActionPerformed(java.awt.event.ActionEvent evt) throws IOException {                                         
		new InterfaceListagemTipoVeiculo().setVisible(true);
	}  
	// fim do método

	/*
	 * Método do Botão Cancelar que retorna a janela sem campos preenchidos
	 * @param evt
	 */
	private void jButtonCancelarActionPerformed(java.awt.event.ActionEvent evt) {
		jButton1.setVisible(true);
		jButton2.setVisible(true);
		jButton3.setVisible(false);
		jButton4.setVisible(false);
		jButton5.setVisible(true);
		jButton6.setVisible(false);
		jCheckBox1.setVisible(false);
		jCheckBox2.setVisible(false);
		jCheckBox3.setVisible(false);
		jCheckBox4.setVisible(false);
		jCheckBox5.setVisible(false);
		jCheckBox6.setVisible(false);
		jCheckBox7.setVisible(false);
		jCheckBox8.setVisible(false);
		jCheckBox9.setVisible(false);
		jCheckBox10.setVisible(false);
		jLabel1.setVisible(true);
		jLabel2.setVisible(false);
		jLabel3.setVisible(false);
		jLabel4.setVisible(false);
		jLabel5.setVisible(false);
		jLabel6.setVisible(false);
		jLabel7.setVisible(false);
		jPanel1.setVisible(true);
		jScrollPane1.setVisible(false);
		jTextArea1.setText("");
		jTextArea1.setVisible(false);
		jTextField1.setEditable(true);
		jTextField1.setText("");
		jTextField1.setVisible(true);
		jTextField2.setText("");
		jTextField2.setVisible(false);
		jTextField3.setText("");
		jTextField3.setVisible(false);
		jTextField4.setText("");
		jTextField4.setVisible(false);
		jTextField5.setText("");
		jTextField5.setVisible(false);
	}
	// fim do método
	
	/*
	 * Método do Botão confirmar que seta os campos preenchidos e altera os 
	 * dados no bando de dados e quase não seja preenchido o modelo, placa
	 * e id do Tipo Veículo ocorre a IOException
	 * @param evt
	 * @throws IOException
	 */
	private void jButtonConfirmaActionPerformed(java.awt.event.ActionEvent evt) throws IOException {
		String placa = jTextField1.getText();
		String modelo = jTextField2.getText();
		String marca = jTextField4.getText();
		String idTipoV = jTextField5.getText();
		String cor = jTextField3.getText();
		String observacao = jTextArea1.getText();
		String opcionais = "";
		if (jCheckBox1.isSelected()) opcionais = "direcao ";		
		if (jCheckBox2.isSelected()) opcionais = opcionais + "Alarme "; 
		if (jCheckBox3.isSelected()) opcionais = opcionais + "CDmp3 ";
		if (jCheckBox4.isSelected()) opcionais = opcionais + "Ar Condicionado ";	
		if (jCheckBox5.isSelected()) opcionais = opcionais + "Teto Solar ";	
		if (jCheckBox6.isSelected()) opcionais = opcionais + "Roda Liga Leve ";	
		if (jCheckBox7.isSelected()) opcionais = opcionais + "Bancos de Couro ";	
		if (jCheckBox8.isSelected()) opcionais = opcionais + "Câmera de Ré ";		
		if (jCheckBox9.isSelected()) opcionais = opcionais + "Air Bag ";		
		if (jCheckBox10.isSelected()) opcionais = opcionais + "Freio Abs ";
		
		if(modelo.equals("") && placa.equals("") && idTipoV.equals("")){
			JOptionPane.showMessageDialog(null,"<html> <font color='black'>Por favor, preencha pelo menos um campo!","Erro",JOptionPane.ERROR_MESSAGE);
		}else{
			int idTV = Integer.parseInt(idTipoV);
			TipoVeiculo tv = new TipoVeiculo(idTV);
			Veiculo novoVeiculo = new Veiculo(placa);
			Veiculo novoVeiculo2 = (Veiculo)persistenciaVeiculo.consultar(novoVeiculo);
		
			if(!modelo.equals("")){
				novoVeiculo2.setModelo(modelo);	
			}
			if(!marca.equals("")){
				novoVeiculo2.setMarca(marca);	
			}
			if(!observacao.equals("")){
				novoVeiculo2.setObservacoes(observacao);
			}
			if(!cor.equals("")){
				novoVeiculo2.setCor(cor);
			}
			if(idTV != 0){
				novoVeiculo2.setTipoVeiculo(tv);
			}
			if(!observacao.equals("")){
				novoVeiculo2.setObservacoes(observacao);
			}
			jButton1.setVisible(true);
			jButton2.setVisible(true);
			jButton3.setVisible(false);
			jButton4.setVisible(false);
			jButton5.setVisible(true);
			jButton6.setVisible(false);
			jCheckBox1.setSelected(false);
			jCheckBox2.setSelected(false);
			jCheckBox3.setSelected(false);
			jCheckBox4.setSelected(false);
			jCheckBox5.setSelected(false);
			jCheckBox6.setSelected(false);
			jCheckBox7.setSelected(false);
			jCheckBox8.setSelected(false);
			jCheckBox9.setSelected(false);
			jCheckBox10.setSelected(false);
			jLabel1.setVisible(true);
			jLabel2.setVisible(false);
			jLabel3.setVisible(false);
			jLabel4.setVisible(false);
			jLabel5.setVisible(false);
			jLabel6.setVisible(false);
			jLabel7.setVisible(false);
			jPanel1.setVisible(true);
			jScrollPane1.setVisible(false);
			jTextArea1.setText("");
			jTextArea1.setVisible(false);
			jTextField1.setEnabled(true);
			jTextField1.setText("");
			jTextField1.setVisible(true);
			jTextField2.setText("");
			jTextField2.setVisible(false);
			jTextField3.setText("");
			jTextField3.setVisible(false);
			jTextField4.setText("");
			jTextField4.setVisible(false);
			jTextField5.setText("");
			jTextField5.setVisible(false);
			persistenciaVeiculo.atualizar(novoVeiculo2);
			JOptionPane.showMessageDialog(null,"<html> <font color='black'>Alteração concluída!","Parabéns!",JOptionPane.INFORMATION_MESSAGE);
		}
	}
	// fim método
	
	/*
	 * Método do Botão ok que após digitar a placa e essa estiver cadastrada
	 * no sistem passa para o passo de alteração do Veículo, se não uma 
	 * excessão ocorre.
	 * @param evt
	 * @throws IOException
	 */
	private void jButtonOkActionPerformed(java.awt.event.ActionEvent evt) throws IOException {
		String placaPesquisa = jTextField1.getText();
		
		if(!placaPesquisa.equals("")){ 
			Veiculo novoVeiculo = new Veiculo(placaPesquisa);
			Veiculo novoVeiculo1 = (Veiculo)persistenciaVeiculo.consultar(novoVeiculo);
			
			if(novoVeiculo1 != null){
				jButton1.setVisible(true);
				jButton2.setVisible(true);
				jButton3.setVisible(true);
				jButton4.setVisible(true);
				jButton5.setVisible(true);
				jButton6.setVisible(true);
				jCheckBox1.setVisible(true);
				jCheckBox2.setVisible(true);
				jCheckBox3.setVisible(true);
				jCheckBox4.setVisible(true);
				jCheckBox5.setVisible(true);
				jCheckBox6.setVisible(true);
				jCheckBox7.setVisible(true);
				jCheckBox8.setVisible(true);
				jCheckBox9.setVisible(true);
				jCheckBox10.setVisible(true);
				jLabel1.setVisible(true);
				jLabel2.setVisible(true);
				jLabel3.setVisible(true);
				jLabel4.setVisible(true);
				jLabel5.setVisible(true);
				jLabel6.setVisible(true);
				jLabel7.setVisible(true);
				jPanel1.setVisible(true);
				jScrollPane1.setVisible(true);
				jTextArea1.setVisible(true);
				jTextField1.setEditable(false);
				jTextField1.setVisible(true);
				jTextField2.setVisible(true);
				jTextField3.setVisible(true);
				jTextField4.setVisible(true);
				jTextField5.setVisible(true);
			}else{
				JOptionPane.showMessageDialog(null,"<html> <font color='black'>Não exite Veículo com essa placa!","Erro",JOptionPane.ERROR_MESSAGE);
				jButton1.setVisible(true);
				jButton2.setVisible(true);
				jButton3.setVisible(false);
				jButton4.setVisible(false);
				jButton5.setVisible(true);
				jButton6.setVisible(false);
				jCheckBox1.setSelected(false);
				jCheckBox2.setSelected(false);
				jCheckBox3.setSelected(false);
				jCheckBox4.setSelected(false);
				jCheckBox5.setSelected(false);
				jCheckBox6.setSelected(false);
				jCheckBox7.setSelected(false);
				jCheckBox8.setSelected(false);
				jCheckBox9.setSelected(false);
				jCheckBox10.setSelected(false);
				jLabel1.setVisible(true);
				jLabel2.setVisible(false);
				jLabel3.setVisible(false);
				jLabel4.setVisible(false);
				jLabel5.setVisible(false);
				jLabel6.setVisible(false);
				jLabel7.setVisible(false);
				jPanel1.setVisible(true);
				jScrollPane1.setVisible(false);
				jTextArea1.setText("");
				jTextArea1.setVisible(false);
				jTextField1.setEnabled(true);
				jTextField1.setText("");
				jTextField1.setVisible(true);
				jTextField2.setText("");
				jTextField2.setVisible(false);
				jTextField3.setText("");
				jTextField3.setVisible(false);
				jTextField4.setText("");
				jTextField4.setVisible(false);
				jTextField5.setText("");
				jTextField5.setVisible(false);
			}
		}else{
			JOptionPane.showMessageDialog(null,"<html> <font color='black'>Digite uma Placa por favor!","Erro",JOptionPane.ERROR_MESSAGE);
		}
	}
	// fim método
	
	private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JCheckBox jCheckBox10;
    private javax.swing.JCheckBox jCheckBox2;
    private javax.swing.JCheckBox jCheckBox3;
    private javax.swing.JCheckBox jCheckBox4;
    private javax.swing.JCheckBox jCheckBox5;
    private javax.swing.JCheckBox jCheckBox6;
    private javax.swing.JCheckBox jCheckBox7;
    private javax.swing.JCheckBox jCheckBox8;
    private javax.swing.JCheckBox jCheckBox9;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField5;
}
// fim classe 
